<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>查看购物车</title>
        <link href="./css/bootstrap.css" rel="stylesheet">
    </head>
    <body>
        <?php session_start(); ?>
        <?php require './check.php'; ?>
        <?php require './mobile.php'; ?>

        <div class="container">
            <div class="row">
                <h3>购物车</h3>
            </div>
            <div class="row">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>货号</th>
                            <th>货品名称</th>
                            <th>价格</th>
                            <th>数量</th>
                            <th>金额</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if (count($_SESSION['cart']) > 0) { ?>
                            <?php foreach ($_SESSION['cart'] as $id => $qty) { ?>
                                <tr>
                                    <td><?php echo $mobiles[$id]['id']; ?></td>
                                    <td><?php echo $mobiles[$id]['name']; ?></td>
                                    <td><?php echo $mobiles[$id]['price']; ?></td>
                                    <td><?php echo $qty; ?></td>
                                    <td><?php echo $mobiles[$id]['price'] * $qty; ?></td>
                                </tr>
                            <?php } ?>
                        <?php } else { ?>
                            <tr>
                                <td colspan="5">购物车是空的.</td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
            <div class="">
                <a class="btn btn-primary" href="./index.php">继续购物</a>
                <a class="btn btn-info" href="clearcart.php">清空购物车</a>
                <a class="btn btn-info" href="#" onclick="alert('还没有实现');">去结算</a>
            </div>
        </div>
    </body>
</html>
